home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 5.0 KB | 178 lines | [TEXT/CWIE] |
- // Release Version: $ ODF 1 $
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
-
- //=======================================================================
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef COMMANDS_H
- #include "Commands.h" // CPizzaCommand
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k" // command numbers
- #endif
-
- // ----- Framework Layer -----
- #ifndef FWCONTXT_H
- #include "FWContxt.h" // FW_CViewContext
- #endif
-
- #ifndef FWEVENTU_H
- #include "FWEventU.h" // FW_IsCommandKeyPressed
- #endif
-
- #include "FWClpCmd.h" // FW_CClipboardCommand
-
- #include "FWDrCmd.h" // FW_CDragCommand, FW_CDropCommand
-
- // ----- OS Layer -----
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h" // FW_CSharedLibraryResourceFile, FW_gInstance
- #endif
-
- #ifndef FWMENU_H
- #include "FWMenu.h" // FW_CMenuBar, etc.
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h" // FW_CMenuEvent, FW_CMouseEvent
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h" // FW_CRectShape
- #endif
-
- #ifndef FWPICSHP_H
- #include "FWPicShp.h" // FW_PPicture, FW_CPictureShape
- #endif
-
- #ifndef FWRRCSHP_H
- #include "FWRRcShp.h" // FW_CRoundRectShape
- #endif
-
- #ifndef FWCMD_H
- #include "FWCmd.h" // FW_CCommand
- #endif
-
- #include "ShapeB.xh"
-
- //========================================================================================
- #ifdef FW_BUILD_MAC
- #pragma segment DataCopy
- #endif
-
- FW_DEFINE_AUTO(CDataCopyFrame)
-
- //========================================================================================
- CDataCopyFrame::CDataCopyFrame(Environment* ev, ODFrame* odFrame,
- FW_CPresentation* presentation, CDataCopyContent* content)
- : FW_CFrame(ev, odFrame, presentation, content->GetPart(ev)),
- FW_MDraggableFrame(ev, this),
- FW_MDroppableFrame(ev, this),
- fDataCopyContent(content)
- {
- }
-
- //----------------------------------------------------------------------------------------
- CDataCopyFrame::~CDataCopyFrame()
- {
- }
-
- //----------------------------------------------------------------------------------------
- FW_Boolean
- CDataCopyFrame::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
- {
- FW_UNUSED(ev);
- FW_CPoint where = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
- this->GetContentView(ev)->FrameToViewContent(ev, where);
- if (theMouseEvent.IsCopyModifier(ev)) {
- this->Drag(ev, theMouseEvent);
- }
- else {
- CPizzaCommand* cmd = FW_NEW(CPizzaCommand, (ev, cMakePizzaCmd, this,
- fDataCopyContent, where) );
- cmd->Execute(ev);
- }
- return true;
- }
-
- //----------------------------------------------------------------------------------------
- void
- CDataCopyFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape) // Override
- {
- FW_CViewContext context(ev, this, odFacet, invalidShape);
- FW_CRect invalidRect = FW_GetShapeBoundingBox(ev, invalidShape);
- // FW_CRectShape::RenderRect(context, invalidRect, FW_kFill, FW_kRGBLightGray);
- FW_CRectShape::RenderRect(context, invalidRect, FW_kFill, FW_kWhiteEraseInk);
-
- // draw pizzas
- CPizzaCollection* list = fDataCopyContent->MyGetPizzaList();
- CPizzaCollectionIterator iter(list);
- CPizza* pizza = NULL;
- ODShape* shape = NULL;
- for (pizza = (CPizza*) iter.First(); iter.IsNotComplete(); pizza = (CPizza*) iter.Next()) {
- if (::FW_IsCommandKeyPressed()) {
- FW_CAcquiredODShape rectShape = ::FW_NewODShape(ev, pizza->GetBounds());
- shape = rectShape->Intersect(ev, invalidShape);
- if ( ! shape->IsEmpty(ev) )
- pizza->Draw(context);
- }
- else
- if (invalidRect.IsIntersecting( pizza->GetBounds() ) )
- pizza->Draw(context);
- }
- }
-
- //----------------------------------------------------------------------------------------
- FW_CClipboardCommand*
- CDataCopyFrame::NewClipboardCommand(Environment* ev, ODCommandID commandID)
- {
- return FW_NEW(FW_CClipboardCommand,
- (ev, commandID, this, ! FW_kCanUndo) );
- }
-
- //----------------------------------------------------------------------------------------
- FW_Boolean
- CDataCopyFrame::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus,
- FW_Boolean isRoot) // Override
- {
- if (hasMenuFocus) {
- FW_Boolean hasRightProperty = false;
- ODType dataType = fDataCopyContent->GetPart(ev)->GetPartKind(ev);
- hasRightProperty = this->HasPropertyOnClipboard(ev, kODPropContents, dataType);
- menuBar->EnableCommand(ev, kODCommandPaste, hasRightProperty);
- }
- return false;
- }
-
- //----------------------------------------------------------------------------------------
- FW_CDropCommand*
- CDataCopyFrame::NewDropCommand(Environment *ev,
- FW_CFrame* frame,
- ODDragItemIterator* dropInfo,
- ODFacet* facet,
- const FW_CPoint& dropPoint)
- {
- return FW_NEW(FW_CDropCommand, (ev, frame, dropInfo, facet, dropPoint, !FW_kCanUndo) );
- }
-
- //----------------------------------------------------------------------------------------
- FW_CDragCommand*
- CDataCopyFrame::NewDragCommand(Environment *ev,
- FW_CFrame* theFrame,
- const FW_CMouseEvent& theMouseEvent)
- {
- return FW_NEW(FW_CDragCommand, (ev, this, !FW_kCanUndo));
- }
-
-